home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / Development Tools & Languages / Macintosh Common Lisp Related / interfaces / speech.lisp < prev    next >
Encoding:
Text File  |  1993-09-16  |  11.5 KB  |  295 lines  |  [TEXT/CCL2]

  1.  
  2. (in-package :TRAPS)
  3.  
  4. (defconstant $gestaltSpeechAttr :|ttsc|);  Gestalt Manager selector for Speech Attributes 
  5. (defconstant $gestaltSpeechMgrPresent 0);  Gestalt bit which indicates that Speech Manager exists 
  6.  
  7. (defconstant $kTextToSpeechSynthType :|ttsc|);  Text-to-Speech Synthesizer component type     
  8. (defconstant $kTextToSpeechVoiceType :|ttvd|);  Text-to-Speech Voice resource type             
  9. (defconstant $kTextToSpeechVoiceFileType :|ttvf|);  Text-to-Speech Voice file type                 
  10. (defconstant $kTextToSpeechVoiceBundleType :|ttvb|);  Text-to-Speech Voice Bundle file type            
  11.  
  12. ;  Speech Manager error codes (Range from 240 - 259) 
  13.  
  14. (defconstant $noSynthFound -240)
  15. (defconstant $synthOpenFailed -241)
  16. (defconstant $synthNotReady -242)
  17. (defconstant $bufTooSmall -243)
  18. (defconstant $voiceNotFound -244)
  19. (defconstant $incompatibleVoice -245)
  20. (defconstant $badDictFormat -246)
  21.  
  22. ;  constants for SpeakBuffer and TextDone callback controlFlags bits 
  23.  
  24. (defconstant $kNoEndingProsody 1)
  25. (defconstant $kNoSpeechInterrupt 2)
  26. (defconstant $kPreflightThenPause 4)
  27.  
  28. ;  constants for StopSpeechAt and PauseSpeechAt 
  29.  
  30. (defconstant $kImmediate 0)
  31. (defconstant $kEndOfWord 1)
  32. (defconstant $kEndOfSentence 2)
  33.  
  34. ;  GetSpeechInfo & SetSpeechInfo selectors 
  35.  
  36. (defconstant $soStatus :|stat|)
  37. (defconstant $soErrors :|erro|)
  38. (defconstant $soInputMode :|inpt|)
  39. (defconstant $soCharacterMode :|char|)
  40. (defconstant $soNumberMode :|nmbr|)
  41. (defconstant $soRate :|rate|)
  42. (defconstant $soPitchBase :|pbas|)
  43. (defconstant $soPitchMod :|pmod|)
  44. (defconstant $soVolume :|volm|)
  45. (defconstant $soSynthType :|vers|)
  46. (defconstant $soRecentSync :|sync|)
  47. (defconstant $soPhonemeSymbols :|phsy|)
  48. (defconstant $soCurrentVoice :|cvox|)
  49. (defconstant $soCommandDelimiter :|dlim|)
  50. (defconstant $soReset :|rset|)
  51. (defconstant $soCurrentA5 :|myA5|)
  52. (defconstant $soRefCon :|refc|)
  53. (defconstant $soTextDoneCallBack :|tdcb|)
  54. (defconstant $soSpeechDoneCallBack :|sdcb|)
  55. (defconstant $soSyncCallBack :|sycb|)
  56. (defconstant $soErrorCallBack :|ercb|)
  57. (defconstant $soPhonemeCallBack :|phcb|)
  58. (defconstant $soWordCallBack :|wdcb|)
  59. (defconstant $soSynthExtension :|xtnd|)
  60.  
  61. ;  Speaking Mode Constants 
  62.  
  63. (defconstant $modeText :|TEXT|) ;  input mode constants     
  64. (defconstant $modeTX "TX")
  65. (defconstant $modePhonemes :|PHON|)
  66. (defconstant $modePH "PH")
  67. (defconstant $modeNormal :|NORM|);  character mode and number mode constants 
  68. (defconstant $modeLiteral :|LTRL|)
  69.  
  70. ;  GetVoiceInfo selectors 
  71.  
  72. (defconstant $soVoiceDescription :|info|);  gets basic voice info 
  73. (defconstant $soVoiceFile :|fref|);  gets voice file ref info 
  74.  
  75. (defconstant $kNeuter 0)
  76. (defconstant $kMale 1)
  77. (defconstant $kFemale 2)
  78.  
  79. (def-mactype :SPEECHCHANNELRECORD (find-mactype :SIGNED-LONG))
  80. (def-mactype :SPEECHCHANNEL (find-mactype :POINTER))
  81. (def-mactype :SPEECHCHANNELPTR (find-mactype :HANDLE))
  82.  
  83. (defrecord VoiceSpec 
  84.    (creator :OSTYPE)            ;  creator id of required synthesizer     
  85.    (id :OSTYPE)                 ;  voice id on the specified synth         
  86.    )
  87. (def-mactype :VOICESPECPTR (find-mactype :POINTER))
  88.  
  89. (defrecord VoiceDescription 
  90.    (length :SIGNED-LONG)        ;  size of structure - set by application     
  91.    (voice :VOICESPEC)           ;  voice creator and id info             
  92.    (version :SIGNED-LONG)       ;  version code for voice                 
  93.    (name (:STRING 63))          ;  name of voice                         
  94.    (comment (:STRING 255))      ;  additional text info about voice         
  95.    (gender :SIGNED-INTEGER)     ;  neuter, male, or female                
  96.    (age :SIGNED-INTEGER)        ;  approximate age in years                 
  97.    (script :SIGNED-INTEGER)     ;  script code of text voice can process 
  98.    (language :SIGNED-INTEGER)   ;  language code of voice output speech     
  99.    (region :SIGNED-INTEGER)     ;  region code of voice output speech     
  100.    (reserved1 :SIGNED-LONG)     ;  always zero - reserved for future use    
  101.    (reserved2 :SIGNED-LONG)     ;  always zero - reserved for future use    
  102.    (reserved3 :SIGNED-LONG)     ;  always zero - reserved for future use    
  103.    (reserved4 :SIGNED-LONG)     ;  always zero - reserved for future use    
  104.    )
  105. (def-mactype :VOICEDESCRIPTIONPTR (find-mactype :POINTER))
  106.  
  107. (defrecord VoiceFileInfo 
  108.    (fileSpec :FSSPEC)           ;  volume, dir, & name information for voice file 
  109.    (resID :SIGNED-INTEGER)      ;  resource id of voice in the file 
  110.    )
  111. (def-mactype :VOICEFILEINFOPTR (find-mactype :POINTER))
  112.  
  113. (defrecord SpeechStatusInfo 
  114.    (outputBusy :BOOLEAN)        ;  TRUE if audio is playing
  115.    (outputPaused :BOOLEAN)      ;  TRUE if channel is paused
  116.    (inputBytesLeft :SIGNED-LONG);  bytes of input left to process
  117.    (phonemeCode :SIGNED-INTEGER);  code for current phoneme
  118.    )
  119. (def-mactype :SPEECHSTATUSINFOPTR (find-mactype :POINTER))
  120.  
  121. (defrecord SpeechModeInfo 
  122.    (inputMode :OSTYPE)          ; 'TEXT' or 'PHON'
  123.    (characterMode :OSTYPE)      ; 'NORM' or 'LTRL'
  124.    (numberMode :OSTYPE)         ; 'NORM' or 'LTRL'
  125.    (symbolMode :OSTYPE)         ; 'NORM' or 'LTRL'
  126.    )
  127. (def-mactype :SPEECHMODEINFOPTR (find-mactype :POINTER))
  128.  
  129. (defrecord SpeechVersionInfo 
  130.    (synthType :OSTYPE)          ;  always ‘ttsc’ 
  131.    (synthSubType :OSTYPE)       ;  Flavor of synth 
  132.    (synthManufacturer :OSTYPE)  ;  synth creator ID 
  133.    (synthFlags :SIGNED-LONG)    ;  synth feature flags 
  134.    (synthVersion :NUMVERSION)   ;  synth version number 
  135.    )
  136. (def-mactype :SPEECHVERSIONINFOPTR (find-mactype :POINTER))
  137.  
  138. (defrecord speechXtndData 
  139.    (synthCreator :OSTYPE)       ; synthesizer ID selector
  140.    (synthData (:ARRAY :CHARACTER 2));  data bytes TBD by synthesizer 
  141.    )
  142.  
  143. (defrecord DelimiterInfo 
  144.    (startDelimiter (:ARRAY :CHARACTER 2))
  145.    (endDelimiter (:ARRAY :CHARACTER 2))
  146.    )
  147.  
  148. (defrecord SpeechErrorInfo 
  149.    (count :SIGNED-INTEGER)      ;  # of errs since last check         
  150.    (oldest :SIGNED-INTEGER)     ;  oldest unread error                 
  151.    (oldPos :SIGNED-LONG)        ;  char position of oldest err         
  152.    (newest :SIGNED-INTEGER)     ;  most recent error                 
  153.    (newPos :SIGNED-LONG)        ;  char position of newest err         
  154.    )
  155.  
  156. (defrecord PhonemeInfo 
  157.    (opcode :SIGNED-INTEGER)     ;  opcode for the phoneme             
  158.    (phStr (:STRING 15))         ;  corresponding char string         
  159.    (exampleStr (:STRING 31))    ;  word that shows use of phoneme     
  160.    (hiliteStart :SIGNED-INTEGER);  segment of example word that         
  161.    (hiliteEnd :SIGNED-INTEGER)  ;  should be hilighted (ala TextEdit) 
  162.    )
  163.  
  164. (defrecord PhonemeDescriptor 
  165.    (phonemeCount :SIGNED-INTEGER);  # of elements         
  166.    (thePhonemes (:ARRAY :PHONEMEINFO 1));  element list         
  167.    )
  168.  
  169.  
  170. (deftrap _SPEECHMANAGERVERSION NIL
  171.    (:STACK :NUMVERSION)
  172.    (:STACK-TRAP #xA800 :D0 (+ (ASH 0 16) 12)))
  173.  
  174.  
  175. (deftrap _MAKEVOICESPEC ((CREATOR :OSTYPE) (ID :OSTYPE) (VOICE (:POINTER :VOICESPEC)))
  176.    (:STACK :SIGNED-INTEGER)
  177.    (:STACK-TRAP #xA800 :D0 (+ (ASH 1540 16) 12) CREATOR ID VOICE))
  178.  
  179. (deftrap _COUNTVOICES ((NUMVOICES :POINTER))
  180.    (:STACK :SIGNED-INTEGER)
  181.    (:STACK-TRAP #xA800 :D0 (+ (ASH 264 16) 12) NUMVOICES))
  182.  
  183. (deftrap _GETINDVOICE ((INDEX :SIGNED-INTEGER) (VOICE (:POINTER :VOICESPEC)))
  184.    (:STACK :SIGNED-INTEGER)
  185.    (:STACK-TRAP #xA800 :D0 (+ (ASH 780 16) 12) INDEX VOICE))
  186.  
  187. (deftrap _GETVOICEDESCRIPTION ((VOICE (:POINTER :VOICESPEC)) (INFO (:POINTER :VOICEDESCRIPTION)) (INFOLENGTH :SIGNED-LONG))
  188.    (:STACK :SIGNED-INTEGER)
  189.    (:STACK-TRAP #xA800 :D0 (+ (ASH 1552 16) 12) VOICE INFO INFOLENGTH))
  190.  
  191. (deftrap _GETVOICEINFO ((VOICE (:POINTER :VOICESPEC)) (SELECTOR :OSTYPE) (VOICEINFO :POINTER))
  192.    (:STACK :SIGNED-INTEGER)
  193.    (:STACK-TRAP #xA800 :D0 (+ (ASH 1556 16) 12) VOICE SELECTOR VOICEINFO))
  194.  
  195.  
  196. (deftrap _STOPSPEECH ((CHAN (:POINTER :SIGNED-LONG)))
  197.    (:STACK :SIGNED-INTEGER)
  198.    (:STACK-TRAP #xA800 :D0 (+ (ASH 556 16) 12) CHAN))
  199.  
  200.  
  201. (deftrap _SETSPEECHRATE ((CHAN (:POINTER :SIGNED-LONG)) (RATE :SIGNED-LONG))
  202.    (:STACK :SIGNED-INTEGER)
  203.    (:STACK-TRAP #xA800 :D0 (+ (ASH 1092 16) 12) CHAN RATE))
  204.  
  205. (deftrap _GETSPEECHRATE ((CHAN (:POINTER :SIGNED-LONG)) (RATE :POINTER))
  206.    (:STACK :SIGNED-INTEGER)
  207.    (:STACK-TRAP #xA800 :D0 (+ (ASH 1096 16) 12) CHAN RATE))
  208.  
  209. (deftrap _SETSPEECHPITCH ((CHAN (:POINTER :SIGNED-LONG)) (PITCH :SIGNED-LONG))
  210.    (:STACK :SIGNED-INTEGER)
  211.    (:STACK-TRAP #xA800 :D0 (+ (ASH 1100 16) 12) CHAN PITCH))
  212.  
  213. (deftrap _GETSPEECHPITCH ((CHAN (:POINTER :SIGNED-LONG)) (PITCH :POINTER))
  214.    (:STACK :SIGNED-INTEGER)
  215.    (:STACK-TRAP #xA800 :D0 (+ (ASH 1104 16) 12) CHAN PITCH))
  216.  
  217.  
  218. (deftrap _USEDICTIONARY ((CHAN (:POINTER :SIGNED-LONG)) (DICTIONARY :HANDLE))
  219.    (:STACK :SIGNED-INTEGER)
  220.    (:STACK-TRAP #xA800 :D0 (+ (ASH 1120 16) 12) CHAN DICTIONARY))
  221.  
  222.  
  223. (deftrap _NEWSPEECHCHANNEL ((VOICE (:POINTER :VOICESPEC)) (CHANPTR (:HANDLE :SIGNED-LONG)))
  224.    (:STACK :SIGNED-INTEGER)
  225.    (:STACK-TRAP #xA800 :D0 (+ (ASH 1048 16) 12) VOICE CHANPTR))
  226.  
  227. (deftrap _DISPOSESPEECHCHANNEL ((CHAN (:POINTER :SIGNED-LONG)))
  228.    (:STACK :SIGNED-INTEGER)
  229.    (:STACK-TRAP #xA800 :D0 (+ (ASH 540 16) 12) CHAN))
  230.  
  231.  
  232. (deftrap _SPEAKSTRING ((S (:STRING 255)))
  233.    (:STACK :SIGNED-INTEGER)
  234.    (:STACK-TRAP #xA800 :D0 (+ (ASH 544 16) 12) S))
  235.  
  236. (deftrap _SPEAKTEXT ((CHAN (:POINTER :SIGNED-LONG)) (TEXTBUF :POINTER) (BYTELEN :SIGNED-LONG))
  237.    (:STACK :SIGNED-INTEGER)
  238.    (:STACK-TRAP #xA800 :D0 (+ (ASH 1572 16) 12) CHAN TEXTBUF BYTELEN))
  239.  
  240. (deftrap _SPEAKBUFFER ((CHAN (:POINTER :SIGNED-LONG)) (TEXTBUF :POINTER) (BYTELEN :SIGNED-LONG) (CONTROLFLAGS :SIGNED-LONG))
  241.    (:STACK :SIGNED-INTEGER)
  242.    (:STACK-TRAP #xA800 :D0 (+ (ASH 2088 16) 12) CHAN TEXTBUF BYTELEN CONTROLFLAGS))
  243.  
  244.  
  245. (deftrap _STOPSPEECHAT ((CHAN (:POINTER :SIGNED-LONG)) (WHERETOSTOP :SIGNED-LONG))
  246.    (:STACK :SIGNED-INTEGER)
  247.    (:STACK-TRAP #xA800 :D0 (+ (ASH 1072 16) 12) CHAN WHERETOSTOP))
  248.  
  249. (deftrap _PAUSESPEECHAT ((CHAN (:POINTER :SIGNED-LONG)) (WHERETOPAUSE :SIGNED-LONG))
  250.    (:STACK :SIGNED-INTEGER)
  251.    (:STACK-TRAP #xA800 :D0 (+ (ASH 1076 16) 12) CHAN WHERETOPAUSE))
  252.  
  253. (deftrap _CONTINUESPEECH ((CHAN (:POINTER :SIGNED-LONG)))
  254.    (:STACK :SIGNED-INTEGER)
  255.    (:STACK-TRAP #xA800 :D0 (+ (ASH 568 16) 12) CHAN))
  256.  
  257.  
  258. (deftrap _SPEECHBUSY NIL
  259.    (:STACK :SIGNED-INTEGER)
  260.    (:STACK-TRAP #xA800 :D0 (+ (ASH 60 16) 12)))
  261.  
  262. (deftrap _SPEECHBUSYSYSTEMWIDE NIL
  263.    (:STACK :SIGNED-INTEGER)
  264.    (:STACK-TRAP #xA800 :D0 (+ (ASH 64 16) 12)))
  265.  
  266.  
  267. (deftrap _GETSPEECHINFO ((CHAN (:POINTER :SIGNED-LONG)) (SELECTOR :OSTYPE) (SPEECHINFO :POINTER))
  268.    (:STACK :SIGNED-INTEGER)
  269.    (:STACK-TRAP #xA800 :D0 (+ (ASH 1624 16) 12) CHAN SELECTOR SPEECHINFO))
  270.  
  271. (deftrap _SETSPEECHINFO ((CHAN (:POINTER :SIGNED-LONG)) (SELECTOR :OSTYPE) (SPEECHINFO :POINTER))
  272.    (:STACK :SIGNED-INTEGER)
  273.    (:STACK-TRAP #xA800 :D0 (+ (ASH 1620 16) 12) CHAN SELECTOR SPEECHINFO))
  274.  
  275.  
  276. (deftrap _TEXTTOPHONEMES ((CHAN (:POINTER :SIGNED-LONG)) (TEXTBUF :POINTER) (TEXTBYTES :SIGNED-LONG) (PHONEMEBUF :HANDLE) (PHONEMEBYTES :POINTER))
  277.    (:STACK :SIGNED-INTEGER)
  278.    (:STACK-TRAP #xA800 :D0 (+ (ASH 2652 16) 12) CHAN TEXTBUF TEXTBYTES PHONEMEBUF PHONEMEBYTES))
  279.  
  280.  
  281. (export '($KFEMALE $KMALE $KNEUTER $SOVOICEFILE $SOVOICEDESCRIPTION
  282.           $MODELITERAL $MODENORMAL $MODEPH $MODEPHONEMES $MODETX $MODETEXT
  283.           $SOSYNTHEXTENSION $SOWORDCALLBACK $SOPHONEMECALLBACK $SOERRORCALLBACK
  284.           $SOSYNCCALLBACK $SOSPEECHDONECALLBACK $SOTEXTDONECALLBACK $SOREFCON
  285.           $SOCURRENTA5 $SORESET $SOCOMMANDDELIMITER $SOCURRENTVOICE
  286.           $SOPHONEMESYMBOLS $SORECENTSYNC $SOSYNTHTYPE $SOVOLUME $SOPITCHMOD
  287.           $SOPITCHBASE $SORATE $SONUMBERMODE $SOCHARACTERMODE $SOINPUTMODE
  288.           $SOERRORS $SOSTATUS $KENDOFSENTENCE $KENDOFWORD $KIMMEDIATE
  289.           $KPREFLIGHTTHENPAUSE $KNOSPEECHINTERRUPT $KNOENDINGPROSODY
  290.           $BADDICTFORMAT $INCOMPATIBLEVOICE $VOICENOTFOUND $BUFTOOSMALL
  291.           $SYNTHNOTREADY $SYNTHOPENFAILED $NOSYNTHFOUND
  292.           $KTEXTTOSPEECHVOICEBUNDLETYPE $KTEXTTOSPEECHVOICEFILETYPE
  293.           $KTEXTTOSPEECHVOICETYPE $KTEXTTOSPEECHSYNTHTYPE
  294.           $GESTALTSPEECHMGRPRESENT $GESTALTSPEECHATTR))
  295. (provide-interface 'speech)